package com.jnchen.jwt.util;

/**
 * 随机工具类
 *
 * @author jnchen
 * @date 2020/10/30 09:37
 */
public class RandomUtil {
    private static final int RANDOM_STR_LEN = 15;

    /**
     * 随机字符串
     */
    public static String randomStr() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < RANDOM_STR_LEN; i++) {
            sb.append((char) ('a' + (int) (Math.random() * 26)));
        }
        return sb.toString();
    }

    /**
     * 随机数字
     */
    public static int randomNumber(int max) {
        return (int) (Math.random() * max);
    }

}
